package com.sping.gobang.mapper;

import com.sping.gobang.pojo.datapbject.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    //用户注册
    void insert(User user);

    //根据用户名，来查询用户的详细信息，用于登陆功能
    User selectByName(String username);

    //总比赛场数+1，获胜场数加+1，天梯分数+30
    void userWin(int userId);

    //总比赛场数+1，获胜场数加不变，天梯分数-30
    void userLose(int userId);


    @Select("SELECT *FROM user where username=#{username}")
    User login(String username);


    @Insert("insert into user(username,password,score,totalCount,winCount) values(#{username},#{password},1000,0,0)")
    boolean register(User user);

    @Select("select * from user where username=#{currentUsername}")
    User getcurrentuser(String username);

    void isDraw(int userId);


}
